<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<jsp:include page="/common/commonCss.jsp"/>
<jsp:include page="/common/commonJs.jsp"/>
<script language="javascript" src="${basePath }commonJs/tags/My97DatePicker/WdatePicker.js"></script>
<script language="javascript" src="${basePath }commonJs/system/update_pwd.js"></script>
<script type="text/javascript">
	var result = true;
	$(document).ready(function() {
		//$("#leaveType").empty();
		$("#leaveList_class").addClass("content_hover");
		loadLeaveType();
		$("#btnSave").click(function() {
			result = valiForm();
			if(result){
				$.messager.confirm('提示', '确认要保存吗?', function(r) {
					if (r) {
						$("#btnType").val("1");
						result = false;
						$("#form1").submit();
					}
				});
			}
		});
		$("#btnSubmit").click(function() {
			result = valiForm();
			if(result){
				$.messager.confirm('提示', '确认要开始该请假流程吗?', function(r) {
					if (r) {
						//result = loadLeaveType();
						$("#btnType").val("2");
						result = false;
						$("#form1").submit();
					}
				});
			}
		});
		
	});
	
	function valiForm(){
		var reason = $("#lveReason").val();
		if($("#leaveType").val() == '-1'){
			alertError("请假类型不能为空!");
			return false;
		}
		if($("#applyBy").val() == ''){
			alertError("请求已超时,请重新登录!");
			return false;
		}
		if($("#lveStartYMD").val() == ''){
			alertError("开始时间不能为空!");
			return false;
		}
		if($("#lveEndYMD").val() == ''){
			alertError("结束时间不能为空!");
			return false;
		}
		if($("#lveEndYMD").val() == $("#lveStartYMD").val() && $("#lveEndHM").val() == $("#lveStartHM").val()){
			alertError("开始和结束时间不能相同!");
			return false;
		}
		
		if($("#lveReason").val() == ''){
			alertError("请假原因不能为空!");
			return false;
		}else{
			if(reason.length > 300){
				alertError("请假原因不能超过300个字符!");
				return false;
			}
		}
		return true;	
	}
	
	//页面进入就加载请假类型列表
	function loadLeaveType(){
		$.ajax({  
            type: "get",  
            url: "${basePath }workflow/leave/findLeaveTypeList.shtml",  
            cache: false,
	        async: false,
	        dataType: 'json',  
            data: {},  //没参数可以删除
            success: function (data) { 
            	$("#leaveType").append("<option value='-1'>---请选择---</option>");
            	$(data).each(function(n){
    					$("#leaveType").append("<option value='"+this.key+"'>"+this.value+"</option>");
    		    });     
            	refreshSelect();
            } ,
            error : function(XMLHttpRequest) {
				ajaxError(XMLHttpRequest);
			} 
        });  
	}
</script>
<title>嘉童游乐中心</title>
</head>
<body class="bg">

<div class="content m_auto">
	<%@include file="../indexPage/index_tab.jsp"%>
    <form action="${basePath }workflow/leave/saveLeave.shtml" method= "post" id="form1" name="form1">
    	<input type="hidden" id="btnType" name ="btnType"/>
    <div class="content_r mt10" >
    <br /><br /><br />
        <dl class="order_add_l_dl w360_c" >
            <dd><label>申请人：</label><input type="text" class="iput_t w200" name="applyBy" id="applyBy" value="${applyName }" disabled></dd>
            <dd><label><span class="color_red ml5">*</span>请假类型：</label>
                <div class="uboxstyle">
                    <select name="pkLvetypeId" id="leaveType">
                    </select>
                </div>
            </dd>
            <dd><label><span class="color_red ml5">*</span>请假开始时间：</label><input title="" type="text" name="lveStartYMD" id="lveStartYMD"
					onClick="WdatePicker({dateFmt:'yyyy/MM/dd',minDate:'%y/%M/%d',maxDate:'#F{$dp.$D(\'lveEndYMD\')}',isShowWeek:true,isShowClear:true,readOnly:true})"
					class="Wdate iput_t w82" readonly />
					<div class="uboxstyle_small">
					<select name="lveStartHM" id="lveStartHM">
						<option value="09:00" selected="selected">09:00</option>
						<option value="09:30">09:30</option>
						<option value="10:00">10:00</option>
						<option value="10:30">10:30</option>
						<option value="11:00">11:00</option>
						<option value="11:30">11:30</option>
						<option value="12:00">12:00</option>
						<option value="12:30">12:30</option>
						<option value="13:00">13:00</option>
						<option value="13:30">13:30</option>
						<option value="14:00">14:00</option>
						<option value="14:30">14:30</option>
						<option value="15:00">15:00</option>
						<option value="15:30">15:30</option>
						<option value="16:00">16:00</option>
						<option value="16:30">16:30</option>
						<option value="17:00">17:00</option>
						<option value="17:30">17:30</option>
						<option value="18:00">18:00</option>
						<option value="18:30">18:30</option>
						<option value="19:00">19:00</option>
						<option value="19:30">19:30</option>
						<option value="20:00">20:00</option>
						<option value="20:30">20:30</option>
						<option value="21:00">21:00</option>
						<option value="21:30">21:30</option>
						<option value="22:00">22:00</option>
						<option value="22:30">22:30</option>
					</select></div></dd>
            <dd><label><span class="color_red ml5">*</span>请假结束时间：</label><input title="" type="text" name="lveEndYMD" id="lveEndYMD"
					onClick="WdatePicker({dateFmt:'yyyy/MM/dd',minDate:'#F{$dp.$D(\'lveStartYMD\') || \'%y/%M/%d\'}',isShowWeek:true,isShowClear:true,readOnly:true})"
					class="Wdate iput_t w82" readonly />
					<div class="uboxstyle_small">
					<select name="lveEndHM" id="lveEndHM">
						<option value="09:00" selected="selected">09:00</option>
						<option value="09:30">09:30</option>
						<option value="10:00">10:00</option>
						<option value="10:30">10:30</option>
						<option value="11:00">11:00</option>
						<option value="11:30">11:30</option>
						<option value="12:00">12:00</option>
						<option value="12:30">12:30</option>
						<option value="13:00">13:00</option>
						<option value="13:30">13:30</option>
						<option value="14:00">14:00</option>
						<option value="14:30">14:30</option>
						<option value="15:00">15:00</option>
						<option value="15:30">15:30</option>
						<option value="16:00">16:00</option>
						<option value="16:30">16:30</option>
						<option value="17:00">17:00</option>
						<option value="17:30">17:30</option>
						<option value="18:00">18:00</option>
						<option value="18:30">18:30</option>
						<option value="19:00">19:00</option>
						<option value="19:30">19:30</option>
						<option value="20:00">20:00</option>
						<option value="20:30">20:30</option>
						<option value="21:00">21:00</option>
						<option value="21:30">21:30</option>
						<option value="22:00">22:00</option>
						<option value="22:30">22:30</option>
					</select></div></dd>
            <dd><label><span class="color_red ml5">*</span>请假原因：</label><textarea name="lveReason" id="lveReason" class="textare w200 h100" rows="10"></textarea></dd>
        </dl>
        <div class="clear"></div>
        <div class="btm_btn mt50">
        	<dl>
                <dd><input type="button" class="btn" id="btnSave" value="保存" /></dd>
                <dd><input type="button" class="btn" id="btnSubmit" value="提交" /></dd>
            	<dd><input type="reset" class="btn" onClick="javascript:history.go(-1);" value="取消" /></dd>
            </dl>
        </div>
    </div>
    </form>
</div>
</body>
</html>